//
//  LXLImageButton.m
//  FZAH
//
//  Created by 李小龙 on 17/3/24.
//  Copyright © 2017年 zdqk. All rights reserved.
//

#import "LXLImageButton.h"

@implementation LXLImageButton

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self configure];
    }
    return self;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        [self configure];
    }
    return self;
}

- (void)configure {
    self.imageView = [[UIImageView alloc] initWithFrame:self.bounds];
    [_imageView setContentMode:UIViewContentModeScaleAspectFill];
    [_imageView setClipsToBounds:YES];
    [self addSubview:_imageView];
    
    [self addSubview:self.playImageView];
    [self addSubview:self.button];
    
    self.deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [_deleteButton setFrame:CGRectMake(self.width-26.0, 0.0, 26.0, 26.0)];
    [_deleteButton setImage:[UIImage imageNamed:@"a"] forState:UIControlStateNormal];
    [self addSubview:_deleteButton];

}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = self.bounds;
    self.deleteButton.frame = CGRectMake(self.width-26.0, 0.0, 26.0, 26.0);
    self.button.frame = self.bounds;
}

- (void)buttonClick:(UIButton *)sender {
    if (self.clickBlock) {
        self.clickBlock();
    }
}

- (UIButton *)button {
    if (!_button) {
        _button = [UIButton buttonWithType:UIButtonTypeCustom];
        [_button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return _button;
}

- (UIImageView *)playImageView {
    if (!_playImageView) {
        _playImageView = [[UIImageView alloc] init];
        _playImageView.hidden = YES;
    }
    return _playImageView;
}


@end
